package com.zhou.gulimall.search.controller;

import com.zhou.gulimall.search.service.MallSearchService;
import com.zhou.gulimall.search.vo.SearchParam;
import com.zhou.gulimall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class SearchController {
    @Autowired
    private MallSearchService mallSearchService;



    @GetMapping("/list.html")
    public String listPage( SearchParam searchParam, Model model){

        //根据页面传递来的查询参数，去es中查找对应的结果
        SearchResult result = mallSearchService.search(searchParam);
        model.addAttribute("result",result);
        return "list";
    }

}
